package com.gxa.accommodation.controller;


import com.gxa.accommodation.entity.Accommodation;
import com.gxa.accommodation.service.AccommodationService;
import com.gxa.common.base.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/accommodation")
public class AccommodationController {

    @Autowired
    AccommodationService accommodationService;

    /**
     * 添加酒店或者民宿
     * @param accommodation
     * @return
     */
    @PostMapping("/addAccommodation")
    public RespResult addAccommodation(@RequestBody Accommodation accommodation){
        return accommodationService.addAccommodation(accommodation);
    }

    /**
     * 添加图片
     * @param file
     * @param id
     * @param request
     * @return
     */
    @PostMapping("/uploadaddAccommodationImg")
    public RespResult uploadaddAccommodationImg(@RequestParam("file") MultipartFile file, @RequestParam("id") Long id, HttpServletRequest request){
        return accommodationService.uploadaddAccommodationImg(file,id,request);
    }

    /**
     * 查询酒店和民宿列表
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/findAccommodationList")
    public RespResult findAccommodation(Integer currentPage,Integer pageSize){
        return accommodationService.findAccommodation(currentPage,pageSize);
    }
}
